//package fun.formoji.commons.oauth.handler;
//
//import com.fasterxml.jackson.databind.ObjectMapper;
//import fun.formoji.commons.model.RestResponse;
//import fun.formoji.commons.model.ServiceCode;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.web.AuthenticationEntryPoint;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
///**
// * <code>WebAuthenticationEntryPoint</code>
// * <desc>
// * 描述：
// * <desc/>
// * <b>Creation Time:</b> 2020/3/10 14:52.
// *
// * @author hshe
// */
//@Component
//@Slf4j
//public class WebAuthenticationEntryPoint implements AuthenticationEntryPoint {
//
//    private final ObjectMapper objectMapper;
//
//    @Autowired
//    public WebAuthenticationEntryPoint(ObjectMapper objectMapper) {
//        this.objectMapper = objectMapper;
//    }
//
//    @Override
//    public void commence(HttpServletRequest httpServletRequest,
//                         HttpServletResponse httpServletResponse,
//                         AuthenticationException e) throws IOException {
//        log.error("WebAuthenticationEntryPoint exception:", e);
//        httpServletResponse.setHeader("Content-Type", "application/json;charset=UTF-8");
//
//
//            objectMapper.writeValue(httpServletResponse.getOutputStream(),
//                    RestResponse.build(ServiceCode.PERMISSION_NO_ACCESS));
//        httpServletResponse.flushBuffer();
//    }
//}
